<?php
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\model;

use app\common\model\BaseModel;

/**
 * 专利-模型
 * @author 牧羊人
 * @since: 2021/12/24
 * Class OfPatent
 * @package app\admin\model
 */
class OfPatent extends BaseModel
{
    // 设置数据表名
    protected $name = "of_patent";

    /**
     * 获取缓存信息
     * @param int $id 记录ID
     * @return \app\common\model\数据信息|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 牧羊人
     * @since: 2021/12/24
     */
    public function getInfo($id)
    {
        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
        if ($info) {

            // 客户信息
            if ($info['company_id']) {
                $companyMod           = new OfCompany();
                $companyInfo          = $companyMod->getInfo($info['company_id']);
                $info['company_name'] = $companyInfo['name'];
            }
            // 合同信息
            if ($info['contract_id']) {
                $contractMod  = new OfContract();
                $contractInfo = $contractMod->getInfo($info['contract_id']);
                if ($contractInfo) {
                    $info['contract_no'] = $contractInfo['contract_no'];
                } else {
                    $info['contract_no'] = '';
                }

            }

            //公告日
            if (!empty($info['issue_date'])) {
                $issue_time           = strtotime($info['issue_date']);
                $info['pay_time_str'] = date("Y-m-d", strtotime("+" . ($info['pay_year'] - 1) . " year", $issue_time));
                $info['end_time_str'] = date("Y-m-d", strtotime("+" . $info['pay_year'] . " year", $issue_time));
            }

            // if ($info['payment_date']) {
            //     $info['payment_date'] = date("Y-m-d", $info['payment_date']);
            // }

        }
        return $info;
    }
}
